//
//  ImageTextFieldView.m
//  WULIHH
//
//  Created by tang on 16/4/25.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "ImageTextFieldView.h"
#import "Header.h"

@interface ImageTextFieldView ()<UITextFieldDelegate>


@end



@implementation ImageTextFieldView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initUI];
        
    }
    return self;
}


-(void)initUI{
    
    //    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 25, 25)];
    //    [imageView setBackgroundColor:[UIColor redColor]];
    //    [imageView.layer setCornerRadius:25.0 / 2.0];
    //    [self addSubview:imageView];
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0.5f, WithView, 0.5f)];
    [lineView setBackgroundColor:[UIColor grayColor]];
    [self addSubview:lineView];
    
    [self setBackgroundColor:[UIColor whiteColor]];
    
    _textfiled = [[UITextField alloc] initWithFrame:CGRectMake(30, 8.0, WithView-60.0, 32.5)];
    [_textfiled setBorderStyle:UITextBorderStyleNone];
    [_textfiled setDelegate:self];
    [_textfiled.layer setCornerRadius: 12];
    [_textfiled setFont:[UIFont systemFontOfSize:13.5]];
    [_textfiled setBackgroundColor:uicolor(230, 230, 230)];
    [self addSubview:_textfiled];
    
    [_textfiled addTarget:self action:@selector(textfiledchange:) forControlEvents:UIControlEventEditingChanged];
    
}



- (void)setContentString:(NSString *)contentString
{
    [_textfiled setText:contentString];
}




- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [_textfiled resignFirstResponder];
    return YES;
}




- (void)textfiledchange:(UITextField *)textField
{
//    NSLog(@"%@", textField.text);
    [_MImageTextFieldViewDelegate changeText:textField.text];
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
